<template>
    <div class="groupitem">
        <!-- 留言内容 -->
        <div>
            <!-- 留言通过props传递 -->
            <slot name="default" :message="props.message"></slot>
        </div>

        <!-- 删除按钮，触发父组件的删除事件 -->
        <button @click="$emit('delete')">删除留言</button>
    </div>
</template>

<script setup lang='ts'>


const props = defineProps<{
    message: String
}>()


// const emit = defineEmits<{
//     (e: 'del'): void
// }>()

// const delMessage = () => {
//     emit('del')
// }

// defineExpose({
//     delMessage,
// })

</script>

<style lang="scss" scoped>
.groupitem {
    border: 3px solid pink;
    margin: 10px;
    padding: 10px;
}


/* 子组件 MessageItem 样式 */
div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

button {
    background-color: #dc3545;
}

button:hover {
    background-color: #c82333;
}
</style>